<template>
  <div class="home-new">
    <HomePanel title="新鲜好物" sub-title="新鲜出炉 品质靠谱">
      <!-- 具名插槽 -->
      <template #right><XtxMore path="/"/></template>
      <!-- 默认插槽 - 面板内容 -->
      <!-- 面板内容 -->
      <transition name="fade">
      <ul class="goods-list" v-if="list.length">
        <li v-for="goods in list" :key="goods.id">
            <RouterLink :to="`/product/${goods.id}`" >
              <img :src="goods.picture" alt="" />
              <p class="name ellipsis">{{ goods.name }}</p>
              <p class="price">&yen;{{ goods.price }}</p>
          </RouterLink>
        </li>
      </ul>
      <!-- 骨架屏 -->
      <HomeSkeleton v-else />
      </transition>
    </HomePanel>
  </div>
</template>
<script>
import HomePanel from './home-panel.vue'
import { ref } from 'vue'
import { findNew } from '@/api/home'
export default {
  components: { HomePanel },
  name: 'HomeNew',
  setup () {
    const list = ref([])
    findNew().then(({ result }) => {
      // console.log(result)
      list.value = result
    })
    return { list }
  }

}
</script>
<style scoped lang="less">
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 406px;
  li {
    width: 306px;
    height: 406px;
    background: #f0f9f4;
    .hoverShadow();
    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding: 12px 30px 0 30px;
      text-align: center;
    }
    .price {
      color: @priceColor;
    }
  }

}
.fade{
  &-leave {
    &-active {
      position: absolute;
      width: 100%;
      transition: opacity .5s .2s;
      z-index: 1;
    }
    &-to {
      opacity: 0;
    }
  }
}
</style>
